package cn.edu.lingnan.fruitshop.controller;


import cn.edu.lingnan.fruitshop.common.JSONResult;
import cn.edu.lingnan.fruitshop.pojo.Goodstable;
import cn.edu.lingnan.fruitshop.service.FocustableService;
import cn.edu.lingnan.fruitshop.service.GoodstableService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.common.JSONResult;
import cn.edu.lingnan.fruitshop.service.FocustableService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.common.JSONResult;
import cn.edu.lingnan.fruitshop.service.FocustableService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.common.JSONResult;
import cn.edu.lingnan.fruitshop.service.FocustableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张小凡
 * @since 2022-01-04
 */
@Controller
@RequestMapping("/focustable")
public class FocustableController {
    @Autowired
    private FocustableService focustableService;

    //加入收藏
    @GetMapping("/focus")
    @ResponseBody
    public JSONResult<Void> focus(Integer goodId, HttpSession session){
        return focustableService.focus(goodId, session);
    }

    //查看我的收藏
    @GetMapping("/myFocus")
    public String myFocus(HttpSession session, Model model){
        return focustableService.myFocus(session, model);
    }

    //删除收藏
    @GetMapping("/deleteFocus")
    public String deleteFocus(Integer focusId){
        return focustableService.deleteFocus(focusId);
    }

}

